import time
import threading

class Timer(threading.Thread):
	def __init__(self, seconds):
		self.runTime = seconds
		threading.Thread.__init__(self)
	def run(self):
		time.sleep(self.runTime)
		timeOut()

def timeOut():
	print 'timeout'
		
class MyTimer(object):
	def __init__(self):
		self.t0 = 0
		self.t =0
	def start(self):
		tempTime = self.getTime()
		self.t=0
		self.t0= time.clock()-tempTime
	def stop(self):
		self.t= time.clock()
		return self.t-self.t0;
	def reset(self):
		self.t = 0
		self.t0=time.clock()
	def getTime(self):
		if self.t0==0:
			return 0        
		elif self.t==0:
			return time.clock()-self.t0
		else:
			return self.t-self.t0